{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}注册{% endblock %}
{% block css %}
    <link rel="stylesheet" href="{% static 'css/register.css' %}">
{% endblock %}
{% block content %}
    <div class="container">
        <div class="col-md-4 col-md-offset-4">
            <br/><br/><br/><br/><br/>
          <form class='form-register' action="/firstWEB/register/" method="post">
  
              {% if message %}
                  <div class="alert alert-warning">{{ message }}</div>
              {% endif %}
  
              {% csrf_token %}
  
              <h2 class="text-center">欢迎注册</h2>
              <div class="form-group">
                  {{ register_form.username.label_tag }}
                  {{ register_form.username}}
              </div>
              <div class="form-group">
                  {{ register_form.password1.label_tag }}
                  {{ register_form.password1 }}
              </div>
              <div class="form-group">
                  {{ register_form.password2.label_tag }}
                  {{ register_form.password2 }}
              </div>
              <div class="form-group">
                  {{ register_form.email.label_tag }}
                  {{ register_form.email }}
              </div>
              <div class="form-group">
                  {{ register_form.sex.label_tag }}
                  {{ register_form.sex }}
              </div>
              <div class="form-group">
                  {{ register_form.captcha.errors }}
                  {{ register_form.captcha.label_tag }}
                  {{ register_form.captcha }}
              </div>
  
              <button type="reset" class="btn btn-default pull-left">重置</button>
              <button type="submit" class="btn btn-primary pull-right">提交</button>
  
          </form>
        </div>
    </div> <!-- /container -->
<script>
            $(function(){
        $('.captcha').css({
        'cursor': 'pointer'
    });
    /*# ajax 刷新*/
        $('.captcha').click(function(){
            console.log('click');
            $.getJSON("/captcha/refresh/",function(result){
                $('.captcha').attr('src', result['image_url']);
                $('#id_captcha_0').val(result['key'])
            });
        });
    })


{% endblock %}